
public class DirectionalLight extends Light{
	
	private Vector direction = null;
	
	public DirectionalLight(){
		this.direction = new Vector();
		this.setColor(new RGB(1.0,1.0,1.0));
	}
	
	public DirectionalLight( Vector direction){
		this();
		this.direction = direction;
	}
	
	public DirectionalLight( Vector direction, RGB color){
		this(direction);
		this.setColor(color);
	}
		
	public void setDirection(Vector direction){
		this.direction = direction;
	}
	
	@Override
	public Vector getDirection(Vector target){
		return this.direction;
	}

	@Override
	public boolean isBlockedByPrimitive(Vector target, Vector viewDirection, Primitive p) {
		//Vector shiftedTarget = Vector.add(target, p.getNormalAt(target, direction).mul(1E-4));
		Vector intersectionPoint = p.intersectionPoint_direction(target, this.direction.mul(-1));
		if( intersectionPoint == null) 
			return false;
		if(Vector.isHiding(target, intersectionPoint, viewDirection, this.direction, p)){
			return true;
		}
		return false;
	}

	@Override
	public RGB getLightningAt(Vector target) {
		return this.getColor();
	}
	
	public static DirectionalLight getDBGdirecLight(){
		Vector direction = new Vector(-1,-1,-1);
		//Vector direction = new Vector(-1,0,0);
		return new DirectionalLight(direction);
	}
	
	public static DirectionalLight getDBGdirecLight2(){
		Vector direction = new Vector(-1,-1,1);
		//Vector direction = new Vector(-1,0,0);
		return new DirectionalLight(direction);
	}
	
}
